﻿using Devil;
using UnityEngine;

namespace GameToolkit
{

    [DefaultExecutionOrder(-1000), AddComponentMenu("")]
    public partial class MainThread : ParallelUnity
    {

        //static int sMainThreadId;

        protected override void OnEnable()
        {
            base.OnEnable();
            //sMainThreadId = Thread.CurrentThread.ManagedThreadId;
            if (Instance == this)
                isSetup = true;
        }

        protected override void OnDisable()
        {
            if (Instance == this)
                isSetup = false;
            base.OnDisable();
        }

        //private void OnApplicationQuit()
        //{
        //    SubThreading.QuitApplication();
        //}

        protected override void Update()
        {
            base.Update();
            ExecuteTask();
        }

        private void LateUpdate()
        {
            ExecuteLateTask();
        }

        private void FixedUpdate()
        {
            ExecuteFixedTask();
        }
    }
}